Skip to content

Refuse writes in a read-only run - #35

Merged
Mpdreamz merged 2 commits into
mainfrom
feature/read-only-guard
Nov 10, 2026
Merged

Mpdreamz merged 2 commits into
mainfrom
feature/read-only-guard

Conversation

@Mpdreamz

Copy link
Copy Markdown
Contributor

Why

A journey run against a live site (docs-builder's post-deploy checks, and a PR check against prod) must not change that site. Declaring a journey read-only isn't enough: a missing annotation would write.

What

  • NetworkGuardOptions with ReadOnly and AllowWrites; Page.GuardNetworkAsync(allow, options). In Fetch.requestPaused, any request that is not GET, HEAD or OPTIONS is failed as blocked by the client. BlockedRequest.RefusedWrite carries the method.
  • JourneyOptions.ReadOnly and WritableUrls (URL globs as in wait --url). A refused write fails the step with Blocked POST <url>: this run is read-only, ….
  • CLI: cdp run --read-only --writable <glob>.
  • @nullean/journeys: readOnly and writableUrls in RunOptions, enforced in page.route with the same message.
  • Docs: a "Read-only runs" section in safety, the CLI option table, and DECISIONS.

Writes are judged after the allow list, so third-party beacons stay reported-not-failed.

Verification

  • New live tests in both runners against a local server that counts writes: fetch POST, form POST, reads, writable URL, writable URL doesn't cover other writes, and no read-only means the write lands. 412 .NET and 310 TS tests pass.
  • Mutated the read-only condition once in each runner: 4 of 6 .NET and 3 of 5 TS tests fail.

No release or publish.

🤖 Generated with Claude Code

@Mpdreamz
Mpdreamz force-pushed the feature/read-only-guard branch 2 times, most recently from cb7496e to b46a57d Compare November 10, 2026 10:27
Mpdreamz and others added 2 commits November 10, 2026 11:56
…runner

A journey run against a live site must not change it. NetworkGuardOptions.ReadOnly refuses every
request that is not GET, HEAD or OPTIONS in Fetch.requestPaused, JourneyOptions.ReadOnly and
WritableUrls expose it, the CLI gets --read-only and --writable, and @nullean/journeys gets
readOnly and writableUrls through page.route. A refused write fails the step that made it.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…dows

Disposing the test server while its serve loop starts another read makes Windows throw
ArgumentException ("The handle is invalid") from BeginGetContext. The loop already returns
on the other disposal errors; this adds that one. It failed the Windows build of two PRs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Mpdreamz
Mpdreamz force-pushed the feature/read-only-guard branch from b948199 to 8ec90f8 Compare November 10, 2026 10:57
@Mpdreamz
Mpdreamz merged commit d5029c9 into main Nov 10, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant